import Vue from 'vue'
import VueRouter from 'vue-router'
// vite里面，不能省略.vue
import Layout from '@/views/layout.vue'
import ArticleDetail from '@/views/article-detail.vue'

// 导入二级路由的四个组件
import Article from '@/views/article.vue'
import Collect from '@/views/collect.vue'
import Like from '@/views/like.vue'
import User from '@/views/user.vue'
Vue.use(VueRouter)

const router = new VueRouter({
    routes: [
        // 1. 路由规则 重定向
        { path: '/', redirect: '/article' },
        {
            path: '/',
            component: Layout,
            // 2. 二级路由，利用children属性配置
            children: [
                { path: '/article', component: Article },
                { path: '/collect', component: Collect },
                { path: '/like', component: Like },
                { path: '/user', component: User }
            ]
        },
        { path: '/detail/:id', component: ArticleDetail }
    ]
})

export default router
